//
//  PingjiaTableViewCell.m
//  XRSquare
//
//  Created by UaenaMo on 2018/8/15.
//  Copyright © 2018年 UaenaMo. All rights reserved.
//

#import "PingjiaTableViewCell.h"

@interface PingjiaTableViewCell ()
{
    UIImageView * contentImage;
    UILabel * titleLabel;
    UILabel * timeLabel;
    UILabel * contentLabel;
    
    NSDictionary * currentData;
}
@end

@implementation PingjiaTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        contentImage = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 50, 50)];
        contentImage.contentMode = UIViewContentModeScaleToFill;
        contentImage.clipsToBounds = YES;
        contentImage.layer.cornerRadius = 25;
        [self addSubview:contentImage];
        
        titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(70, 10, ScreenWidth, 20)];
        titleLabel.font = [UIFont systemFontOfSize:15];
        [self addSubview:titleLabel];
        
        timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(70, 40, ScreenWidth, 20)];
        timeLabel.font = [UIFont systemFontOfSize:12];
        [self addSubview:timeLabel];
        
        contentLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 70, ScreenWidth, 20)];
        contentLabel.font = [UIFont systemFontOfSize:15];
        [self addSubview:contentLabel];
        
        UIView * line = [[UIView alloc]initWithFrame:CGRectMake(0, 99, ScreenWidth, 1)];
        line.backgroundColor = [UIColor colorFromHexCode:@"f3f3f3"];
        [self addSubview:line];
        
        UIButton * up = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 70)];
        [up addTarget:self action:@selector(upAction) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:up];
    }
    return self;
}

+(CGFloat)height
{
    return 100;
}

-(void)loadData:(NSDictionary *)data
{
    
    currentData = data;
    
    [contentImage sd_setImageWithURL:[NSURL URLWithString:[data objectForKey:@"HeadPic"]]];
    titleLabel.text = [data objectForKey:@"Name"];
    timeLabel.text = [data objectForKey:@"Time"];
    contentLabel.text = [data objectForKey:@"Description"];
    
}

-(void)upAction
{
    [self.delegate userId:[currentData objectForKey:@"TargetUID"]];
}



- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
